escape or reject a bare carriage return in multiline strings - #539
escape or reject a bare carriage return in multiline strings#539netliomax25-code wants to merge 2 commits into
Conversation
|
any update? |
|
Conflicts to be resolved |
77e61fb to
1b23b94
Compare
|
Rebased onto master, conflicts resolved. The conflict was with the leading-newline fix from #551 in |
davidpavlovschi
left a comment
There was a problem hiding this comment.
The bare-CR check now distinguishes CRLF line endings from lone carriage-return control characters in both multiline forms. I verified the focused string API suite (42 tests) and 780 generated combinations of text, LF, CRLF, and bare CR: multiline basic strings round-trip through tomlkit and remain valid for tomllib, while multiline literals reject exactly the values containing a CR outside a CRLF pair. The leading-newline behavior from #551 remains intact.
Summary
String.from_rawbuilds a multiline basic string by escaping every control character except a line feed and a carriage return, so a lone CR (one that is not the CR of a CRLF pair) is written out raw.invalid_sequences, so a lone CR there is neither escaped nor rejected.tomlkit.string(value, multiline=True)and its literal variant emit a document with a raw lone CR, which the tomlkit parser and the stdlibtomllibboth reject as a control character, so the value stops round-tripping.\rfor multiline basic strings, and raiseInvalidStringErrorfor multiline literal strings; LF and CRLF line endings are left untouched.Agent Drafting Metadata